package com.yubest.springbootsecurity.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class AuthUtil {

    public static String encode(String password) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.encode(password);
    }

    public static boolean matches(String rawPassword, String encodedPassword) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(rawPassword, encodedPassword);
    }

    public static void main(String[] args) {
//        for (int i = 0; i < 5; i++) {
//            System.out.println(encode("123456"));
//        }

        System.out.println(matches("123456", "$2a$10$cxnoKwZQZlsHhWTOa3OM8eSVlDNTnkYYiOtS7uDN28mG3z2.okfbe"));
    }
}
